package xiaohu.day5.HJ52;

import java.util.Scanner;

public class Main2 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str1 = sc.nextLine();
        String str2 = sc.nextLine();
        int[][] res = new int[str1.length()][str2.length()];
        for (int i = 0; i < str1.length(); i++) {
            for (int j = 0; j < str2.length(); j++) {
                char c1 = str1.charAt(i);
                char c2 = str2.charAt(j);
                if (i == 0) {
                    res[i][j] = str2.substring(0, j + 1).indexOf(c1) >= 0 ? j : j + 1;
                    continue;
                }
                if (j == 0) {
                    res[i][j] = str1.substring(0, i + 1).indexOf(c2) >= 0 ? i : i + 1;
                    continue;
                }
                if (c1 == c2) {
                    res[i][j] = res[i - 1][j - 1];
                } else {
                    int r1 = res[i][j - 1] + 1;
                    int r2 = res[i - 1][j] + 1;
                    int r3 = res[i - 1][j - 1] + 1;
                    res[i][j] = Math.min(r1, Math.min(r2, r3));
                }
            }
        }
        System.out.println(res[str1.length() - 1][str2.length() - 1]);
    }
}
